package avicit.bdp.dgs.qa.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2023-03-15
 * @类说明：RuleTemplateDTO
 * @修改记录：
 * @注意事项：
 * @主要功能：规则模板DTO
 */
@ApiModel(value = "RuleTemplateDTO", description = "规则模板DTO")
@Table(name = "bdp_dgs_qa_rule_template")
public class RuleTemplateDTO extends BaseDTO {
    /**
     * 主键
     */
    @Id
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "id")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    /**
     * 名称
     */
    @LogField
    @ApiModelProperty(value = "名称")
    @FieldRemark(column = "name", field = "name", name = "名称")
    @Column(name = "name")
    private String name;

    /**
     * 描述
     */
    @LogField
    @ApiModelProperty(value = "描述")
    @FieldRemark(column = "remark", field = "remark", name = "描述")
    @Column(name = "remark")
    private String remark;

    /**
     * 校验类型，0:单表校验、1:跨表比对、2:跨库比对、3:文件校验、4:单指标校验、5:多指标校验、6:根据数据标准校验
     */
    @LogField
    @ApiModelProperty(value = "校验类型，0:单表校验、1:跨表比对、2:跨库比对、3:文件校验、4:单指标校验、5:多指标校验、6:根据数据标准校验")
    @FieldRemark(column = "measureType", field = "measureType", name = "measureType")
    @Column(name = "measure_type")
    private Integer measureType;
    @Transient
    private String measureTypeName;

    /**
     * 模板类型
     */
    @LogField
    @ApiModelProperty(value = "模板类型，0:内置模板、1:自定义模板")
    @FieldRemark(column = "templateType", field = "templateType", name = "templateType")
    @Column(name = "template_type")
    private Integer templateType;
    @Transient
    private String templateTypeName;

    /**
     * 规则类型
     */
    @LogField
    @ApiModelProperty(value = "规则类型，0:库级、1:表级、2:字段级、3:跨字段级、4:跨源级、5:文件级")
    @FieldRemark(column = "ruleType", field = "ruleType", name = "ruleType")
    @Column(name = "rule_type")
    private Integer ruleType;
    @Transient
    private String ruleTypeName;

    /**
     * 规则维度
     */
    @LogField
    @ApiModelProperty(value = "规则维度,0:完整性、1:有效性、2:及时性、3:一致性、4:准确性、5:唯一性")
    @FieldRemark(column = "ruleDimension", field = "ruleDimension", name = "ruleDimension")
    @Column(name = "rule_dimension")
    private Integer ruleDimension;
    @Transient
    private String ruleDimensionName;

    /**
     * 统计数值类型
     */
    @LogField
    @ApiModelProperty(value = "统计数值类型，0:固定值、1:字段")
    @FieldRemark(column = "statDataType", field = "statDataType", name = "统计数值类型")
    @Column(name = "stat_data_type")
    private Integer statDataType;
    @Transient
    private String statDataTypeName;

    /**
     * 模板输出名称
     */
    @LogField
    @ApiModelProperty(value = "模板输出名称")
    @FieldRemark(column = "outputName", field = "outputName", name = "outputName")
    @Column(name = "output_name")
    private String outputName;

    /**
     * 自定义SQL
     */
    @LogField
    @ApiModelProperty(value = "自定义SQL")
    @FieldRemark(column = "customSQL", field = "customSQL", name = "customSQL")
    @Column(name = "custom_sql")
    private String customSQL;

    /**
     * 异常数据SQL
     */
    @LogField
    @ApiModelProperty(value = "异常数据SQL")
    @FieldRemark(column = "abnomalSQL", field = "abnomalSQL", name = "abnomalSQL")
    @Column(name = "abnomal_sql")
    private String abnomalSQL;

    /**
     * 模板版本
     */
    @LogField
    @ApiModelProperty(value = "模板版本")
    @FieldRemark(column = "templateVersion", field = "templateVersion", name = "templateVersion")
    @Column(name = "template_version")
    private String templateVersion;

    /**
     * 模板状态,0:编辑中、1:已发布、2:已废止、3：审批中、4：已驳回
     */
    @LogField
    @ApiModelProperty(value = "模板状态,0:编辑中、1:已发布、2:已废止、3：审批中、4：已驳回")
    @FieldRemark(column = "state", field = "state", name = "state")
    @Column(name = "state")
    private Integer state;
    @Transient
    private String stateName;

    /**
     * 文件校验使用，算法类型,0:关键字检查
     */
    @LogField
    @ApiModelProperty(value = "算法类型,0:关键字检查")
    @FieldRemark(column = "algo_type", field = "algoType", name = "算法类型,0:关键字检查")
    @Column(name = "algo_type")
    private Integer algoType;

    /**
     * 构建模板分类树使用
     */
    @Transient
    private Integer leaf;
    @Transient
    List<RuleTemplateDTO> children;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getMeasureType() {
        return measureType;
    }

    public void setMeasureType(Integer measureType) {
        this.measureType = measureType;
    }

    public String getMeasureTypeName() {
        return measureTypeName;
    }

    public void setMeasureTypeName(String measureTypeName) {
        this.measureTypeName = measureTypeName;
    }

    public Integer getTemplateType() {
        return templateType;
    }

    public void setTemplateType(Integer templateType) {
        this.templateType = templateType;
    }

    public String getTemplateTypeName() {
        return templateTypeName;
    }

    public void setTemplateTypeName(String templateTypeName) {
        this.templateTypeName = templateTypeName;
    }

    public Integer getRuleType() {
        return ruleType;
    }

    public void setRuleType(Integer ruleType) {
        this.ruleType = ruleType;
    }

    public String getRuleTypeName() {
        return ruleTypeName;
    }

    public void setRuleTypeName(String ruleTypeName) {
        this.ruleTypeName = ruleTypeName;
    }

    public Integer getRuleDimension() {
        return ruleDimension;
    }

    public void setRuleDimension(Integer ruleDimension) {
        this.ruleDimension = ruleDimension;
    }

    public String getRuleDimensionName() {
        return ruleDimensionName;
    }

    public void setRuleDimensionName(String ruleDimensionName) {
        this.ruleDimensionName = ruleDimensionName;
    }

    public Integer getStatDataType() {
        return statDataType;
    }

    public void setStatDataType(Integer statDataType) {
        this.statDataType = statDataType;
    }

    public String getStatDataTypeName() {
        return statDataTypeName;
    }

    public void setStatDataTypeName(String statDataTypeName) {
        this.statDataTypeName = statDataTypeName;
    }

    public String getOutputName() {
        return outputName;
    }

    public void setOutputName(String outputName) {
        this.outputName = outputName;
    }

    public String getCustomSQL() {
        return customSQL;
    }

    public void setCustomSQL(String customSQL) {
        this.customSQL = customSQL;
    }

    public String getAbnomalSQL() {
        return abnomalSQL;
    }

    public void setAbnomalSQL(String abnomalSQL) {
        this.abnomalSQL = abnomalSQL;
    }

    public String getTemplateVersion() {
        return templateVersion;
    }

    public void setTemplateVersion(String templateVersion) {
        this.templateVersion = templateVersion;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getStateName() {
        return stateName;
    }

    public void setStateName(String stateName) {
        this.stateName = stateName;
    }

    public Integer getAlgoType() {
        return algoType;
    }

    public void setAlgoType(Integer algoType) {
        this.algoType = algoType;
    }

    public Integer getLeaf() {
        return leaf;
    }

    public void setLeaf(Integer leaf) {
        this.leaf = leaf;
    }

    public List<RuleTemplateDTO> getChildren() {
        return children;
    }

    public void setChildren(List<RuleTemplateDTO> children) {
        this.children = children;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "规则模板模块";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "规则模板";
        } else {
            return super.logTitle;
        }
    }
}
